<template>

	<view class="reg-container">
		<view class="reg-title">用户注册</view>

		<view class="form-group">
			<view class="input-wrapper">
				<input type="text" placeholder="请输入用户名" bindinput="onUsernameInput" v-model="loginname" />
			</view>
		</view>

		<view class="form-group">
			<view class="input-wrapper">
				<input type="password" placeholder="请输入密码" bindinput="onPasswordInput" v-model="password"
					password="true" />
			</view>
		</view>

		<button class="reg-btn" @click="goreg">立即注册</button>

		<view class="login-link">
			<text>已有账号？</text>
			<text class="link" @click="gologin">去登录</text>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		onLoad
	} from "@dcloudio/uni-app"
	let loginname = ref("");
	let password = ref("")

	onLoad((option) => {})

	function gologin() {
		uni.navigateTo({
			url: "/pages/login/login"
		})
	}

	function goreg() {
		uni.request({
			url: "https://www.xuzhixiang.top:30001/api/user/reg",
			method: "POST",
			data: {
				loginname: loginname.value,
				password: password.value
			},
			success: (res) => {
				console.log(res)
				uni.navigateTo({
					url: "/pages/login/login"
				})
			}
		})
	}
</script>

<style>
	/* 页面容器样式 */
	.reg-container {
		padding: 40rpx;
		box-sizing: border-box;
		height: 100vh;
		background-color: #f5f5f5;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	/* 标题样式 */
	.reg-title {
		font-size: 40rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 60rpx;
		margin-top: 100rpx;
	}

	/* 表单组样式 */
	.form-group {
		width: 100%;
		margin-bottom: 30rpx;
	}

	/* 输入框包装器样式 */
	.input-wrapper {
		display: flex;
		align-items: center;
		background-color: #fff;
		border-radius: 8rpx;
		padding: 0 20rpx;
		height: 90rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	/* 图标样式 */
	.input-wrapper image {
		width: 40rpx;
		height: 40rpx;
		margin-right: 20rpx;
	}

	/* 输入框样式 */
	.input-wrapper input {
		flex: 1;
		height: 90rpx;
		font-size: 28rpx;
		color: #333;
	}

	/* 注册按钮样式 */
	.reg-btn {
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		background-color: #e64340;
		color: #fff;
		font-size: 32rpx;
		border-radius: 45rpx;
		margin-top: 50rpx;
		margin-bottom: 30rpx;
	}

	/* 登录链接样式 */
	.login-link {
		display: flex;
		align-items: center;
		font-size: 26rpx;
		color: #666;
	}

	/* 链接样式 */
	.link {
		color: #e64340;
		margin-left: 10rpx;
		text-decoration: underline;
	}
</style>